﻿#region Using Directives

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using GeekRule.ORM.Entities;

#endregion

namespace GeekRule.ORM
{
    /// <summary>
    /// Interface for the QueryManager implementation
    /// </summary>
    interface IQueryManager : IDisposable
    {
        // DataSet queries
        DataSet ExecuteDataSet(DbCommand command);
        DataSet ExecuteDataSet(DbTransaction transaction, DbCommand command);
        DataSet ExecuteDataSet(CommandType commandType, string commandText, params object[] parameterValues);
        DataSet ExecuteDataSet(DbTransaction transaction, CommandType commandType, string commandText, params object[] parameterValues);
        DataSet ExecuteDataSet(string storedProcedureName, params object[] parameterValues);
        DataSet ExecuteDataSet(DbTransaction transaction, string storedProcedureName, params object[] parameterValues);

        // Non-query queries
        int ExecuteNonQuery(DbCommand command);
        int ExecuteNonQuery(DbTransaction transaction, DbCommand command);
        int ExecuteNonQuery(CommandType commandType, string commandText, params object[] parameterValues);
        int ExecuteNonQuery(DbTransaction transaction, CommandType commandType, string commandText, params object[] parameterValues);
        int ExecuteNonQuery(string storedProcedureName, params object[] parameterValues);
        int ExecuteNonQuery(DbTransaction transaction, string storedProcedureName, params object[] parameterValues);

        // Strongly-typed queries
        List<T> ExecuteQuery<T>(DbCommand command) where T : EntityBase;
        List<T> ExecuteQuery<T>(DbTransaction transaction, DbCommand command) where T : EntityBase;
        List<T> ExecuteQuery<T>(CommandType commandType, string commandText, params object[] parameterValues) where T : EntityBase;
        List<T> ExecuteQuery<T>(DbTransaction transaction, CommandType commandType, string commandText, params object[] parameterValues) where T : EntityBase;
        List<T> ExecuteQuery<T>(string storedProcedureName, params object[] parameterValues) where T : EntityBase;
        List<T> ExecuteQuery<T>(DbTransaction transaction, string storedProcedureName, params object[] parameterValues) where T : EntityBase;

        // Multi-result queries
        void ExecuteMultiResultQuery(DbCommand command);
        List<T> GetResult<T>() where T : EntityBase;
        
        // IDataReader queries
        IDataReader ExecuteReader(DbCommand command);
        IDataReader ExecuteReader(DbTransaction transaction, DbCommand command);
        IDataReader ExecuteReader(CommandType commandType, string commandText, params object[] parameterValues);
        IDataReader ExecuteReader(DbTransaction transaction, CommandType commandType, string commandText, params object[] parameterValues);
        IDataReader ExecuteReader(string storedProcedureName, params object[] parameterValues);
        IDataReader ExecuteReader(DbTransaction transaction, string storedProcedureName, params object[] parameterValues);
        
        // Scalar queries
        object ExecuteScalar(DbCommand command);
        object ExecuteScalar(DbTransaction transaction, DbCommand command);
        object ExecuteScalar(CommandType commandType, string commandText, params object[] parameterValues);
        object ExecuteScalar(DbTransaction transaction, CommandType commandType, string commandText, params object[] parameterValues);
        object ExecuteScalar(string storedProcedureName, params object[] parameterValues);
        object ExecuteScalar(DbTransaction transaction, string storedProcedureName, params object[] parameterValues);

        // Command builders
        DbCommand GetSqlStringCommand(string query, params object[] parameterValues);
        DbCommand GetStoredProcedureCommand(string storedProcedureName, params object[] parameterValues);
    }
}
